#include <set>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <set>
#include <map>


using namespace std;
const int inf = 0x3f3f3f3f;
const int N = 1e5+5;

int c[N<<2],a[N];
long long dp[N];
void up(int rt){
    if(a[c[rt<<1]]>=a[c[rt<<1|1]])
        c[rt] = c[rt<<1];
    else c[rt] = c[rt<<1|1];
}
void build(int rt,int l,int r){
    if(l==r){
        c[rt] = l;
        return;
    }
    int mid = (l+r)>>1;
    build(rt<<1,l,mid);
    build(rt<<1|1,mid+1,r);
    up(rt);
}

int ask(int rt,int l,int r,int x,int y){
    if(x<=l&&y>=r) return c[rt];
    int ls = -1,rs = -1,mid = (l+r)>>1;
    if(x<=mid) ls = ask(rt<<1,l,mid,x,y);
    if(y>mid) rs = ask(rt<<1|1,mid+1,r,x,y);
    if(ls==-1) return rs;
    if(rs==-1) return ls;
    if(a[ls]>=a[rs]) return ls;
    else return rs;
}

int main(){
    int n;
    scanf("%d",&n);
    for(int i=1;i<n;i++){
        scanf("%d",&a[i]);
    }
    a[n] = n;
    long long ret = 0;
    build(1,1,n);
    for(int i=n-1;i>0;i--){
        int pos = ask(1,1,n,i+1,a[i]);
        dp[i] = dp[pos]+(n-i)-(a[i]-pos);
 //       cout << "ans: " << dp[i] << endl;
 //       cout << "pos: " << pos << endl;
        ret += dp[i];
    }
    printf("%I64d\n",ret);
    return 0;
}
